﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class CommonPages_ExcelOutput : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string filename = Request.QueryString["filename"];

        DownloadFile(HttpUtility.UrlDecode(filename, System.Text.Encoding.UTF8));
    }

    private void DownloadFile(string filename)
    {
        Response.Clear();

        Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8));

        Response.ContentType = "application/octet-stream";

        string filepath = Server.MapPath("~/TmpFile/" + filename);

        Response.TransmitFile(filepath);

        Response.End();
    }
}
